﻿<?php
$url='http://www.baidu.com';
// $html=file_get_contents($url);
// echo $html;


// 方式二
$fp=fopen($url,'r');
// pre(stream_get_meta_data($fp));
// pre(stream_get_contents($fp));
stream_get_meta_data($fp);
$result='';
while(!feof($fp)){
	$result.=fgets($fp,1024);
}
// echo 'url Body:'.$result;
fclose($fp);
// 方式三
$post_data=['key'=>'value','key1'=>'value2'];
$data=http_build_query($post_data);
$opt=array(
  'http'=>array(
    'method' => 'POST',
	'header'=> "Content-type: application/x-www-form-urlencodedrn" .
	"Content-Length: " . strlen($data) . "rn",
    'content' => $data
  )
);

$context=stream_context_create($opt);
// echo $context;

$res=file_get_contents($url,false,$context);
echo $res;
function pre($data){
	echo '<pre>';
	print_r($data);
}